/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
				\file		CC_DrawSpace.h
				\date		june 2010
				\author		TNick

				\brief		Contains the definition of CC_DrawSpace class and related


	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	Please read ReadMe.txt and Licence.txt in root folder
	~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef		__CC_DRAWSPACE_INC__
#define		__CC_DRAWSPACE_INC__
#ifdef		__cplusplus
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

class	CC_Draw;
class	CC_GIP;

#include	<generic/cc_l2dn.h>
#include	"CC_Err.h"
#include	<base/uni_prp/PrpAgreg.h>
#include	<base/uni_prp/PrpHost.h>

/*  INCLUDES    ============================================================ */
//
//
//
//


/// Basic drawing space; model or paper, they all have same class
/**
*	One instance of this class is created when any CC_Draw is created to
*	represent the only one instance that can't be removed (but can be replaced). @n
*	The class that is inherited (CC_L2DN) manages the chain of spaces in a drawing
*	and stores the name.
*/
class	CC_DrawSpace	: public CC_L2DN, public PrpHost {


	//
	//
	//
	//
	/*  DEFINITIONS    --------------------------------------------------------- */
	friend class CC_Layer;
	friend class CC_Draw;

	/*  DEFINITIONS    ========================================================= */
	//
	//
	//
	//
	/*  DATA    ---------------------------------------------------------------- */
protected:
	/// list of private layers to this space
	CC_HDL2DN			Layers;

	/// pointer to the drawing where this belongs
	CC_Draw*			pAscDraw;

	/// graphical data
	CC_GIP*				grd;


	/*  DATA    ================================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ----------------------------------------------------------- */



	/// constructor; must enshure that only one instance is present
private: CC_DrawSpace() : CC_L2DN()
	{ pAscDraw = NULL; grd = NULL; }

	/// destructor; will free resources; not virtual;
public: virtual ~CC_DrawSpace(){}


	/// function used to create a new drawing space
public: static CCERR::EERRORS		create		(
		CC_Draw*		pDraw,	/**< pointer to container; may be NULL */
		CC_DrawSpace*	pTmpl,	/**< pointer to space used as template; may be NULL */
		QString			strNewName,/**< name of this space; must be either an empty
	 string or an unique name*/
		CC_DrawSpace**	pOut,	/**< if succesfull, pointer to created layer */
		CC_Err*			pErr	/**< pointer to error correlation structure */
		);

	/// associates an unbound drawing space with a drawing
	/**
	*	Unbound spaces reslut from using CC_DrawSpace::create without a drawing as
	*	argument.
	*/
public: CCERR::EERRORS				bind		(
		CC_Draw*		pDraw,	/**< pointer to container; must not be NULL */
		CC_Err*			pErr	/**< pointer to error correlation structure */
		);


	/* >>>>>>>>>>>>>>>>>>>>>>>>>>>   PrpHost   <<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
	/// get the list of properties a a list of pointers to PrpAgreg instances
	/**
	*	@return		array allocated using new[]; the ownership of the array
		 passes to caller; may be NULL for memory failures or if the item
		 has no properties
	*/
	virtual PrpAgreg**	propList		(
		int*		p_count	/**< pointer to variable that recives
		the number of elements in the list */
	) const { *p_count = 0; return NULL; }


	/// informs the item about a chnge in properties
	/**
	*	the item must determine inside if it supports this property and,
	*	if it does, shall update it's value. If the item does not support
	*	this feature, it should silently ignore this call.
	*/
	virtual void		propChanged		(
		PrpAgreg*	p_new_val	/**< pointer to changed value */
	) { Q_UNUSED(p_new_val); }



	/* >>>>>>>>>>>>>>>>>>>>>>>>>>>  FILE I/O   <<<<<<<<<<<<<<<<<<<<<<<<<<<<< */

	/// saves the data regarding this class to a stream in CASP_1 format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS	Save_CASP_1	(QDataStream* pStream, CC_Err* pErr);

	/// loads the data regarding this class from a stream in CASP_1 format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS	Load_CASP_1	(QDataStream* pStream, CC_Err* pErr);



	/// saves the data regarding this class to a stream in DXF format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS	Save_DXF	(QDataStream* pStream, CC_Err* pErr);

	/// loads the data regarding this class from a stream in DXF format
	/*
	*	@return		true all went OK; false some went wrong
	*/
public: CCERR::EERRORS	Load_DXF	(QDataStream* pStream, CC_Err* pErr);

	/*  FUNCTIONS    =========================================================== */
	//
	//
	//
	//

};	/*	class	CC_DrawSpace	*/
//
//
//
//
#endif	//	__cplusplus
#endif	//	__CC_DRAWSPACE_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
